﻿using System.Windows.Forms;

namespace DevTeam
{
    public partial class DevPopupForm : DevForm
    {
        public DevPopupForm()
        {
            InitializeComponent();
            this.KeyPreview = true;

            this.KeyDown += new KeyEventHandler(XPopupForm_KeyDown);

            FooterBar.Visible = false;
        }

        public string FooterText
        {
            set
            {
                if (value.StartsWith(">"))
                {
                    FooterLabel.TextAlignment = System.Drawing.StringAlignment.Far;
                    value = value.Substring(1);
                }

                FooterLabel.Caption = value;
                FooterLabel.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                FooterBar.Visible = true;

            }
        }

        private bool escCloses = true;
        public bool ESCCloses
        {
            get
            {
                return escCloses;
            }
            set
            {
                escCloses = value;
            }
        }

        void XPopupForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (ESCCloses && e.KeyCode == Keys.Escape)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                this.Close();
            }
        }

        private void XPopupForm_Load(object sender, System.EventArgs e)
        {
        }
    }
}